<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>设置航段库存setLegInventory.html</title>
	</head>
	<link rel="stylesheet" href="../css/common.css" />
	<link rel="stylesheet" href="../css/less/common_less.css" />
	<style>
		body{
			background:#ffffff;
		}
		input{
			font-size:14px;
		}
		table {						
			border-collapse:collapse;	
			width:890px;
			margin:30px auto;	
		}
		th{
			font-weight:normal;		
			background:#f0eeef;
		}
		td{
			text-align:center;
			background:#fafafa;
		}
		table td,th{
			height:32px;
			border:1px solid #e7e9e8;
			
		}		
		input{
			
			width:50px;
			height:25px;
			background:#fafafa;
			border:1px solid #dadada;
			text-align:center;
			font-family:"微软雅黑";
		}
		.btn{
			width:100%;
			height:50px;
			position:fixed;
			bottom:0;
			left:0;
			text-align:center;
		}
		.btn button{
			width:116px;
			height:30px;
			border:none;
			font-family:"微软雅黑";
			color:white;
			outline:none;
			cursor:pointer;			
		}
		.btn1{
			background:#01a998;
		}
		.btn2{
			background:#a1a4a9;
		}
		.legflight{
		padding:10px;
		padding-top:20px;
		}
		.legflight select{
		width:210px;
		height:24px;
		boder:1px solid #dadada;
		font-family:"微软雅黑";
		}
		input[type=radio]{
			position:relative;
			top:5px;
			margin:0 5px;
		}
		.flightBoatTab table input{
			border:none;
		}
		.font14px{
		font-size: 14px;
		}
		.editBtn{
			width:72px;
			height:26px;
			float:right;
			margin-right:40px;
		}
		.star{
			display:none;
		}
	</style>
	<body>
	<p class="legflight f60666" id="setLeg">航段选择：
		<select id="segflight">
		
		</select>
<!--	<button class="editBtn searchBtn" >编辑</button>    -->	
	</p>
	
	<div class="mainTab"></div>
	<p class="legflight f60666">航节选择：
		<select id="flightBoat">
		
		</select>
	</p>  
	<div class="flightBoatTab"></div>
	  
	<div style="height:50px;"></div>	 
		<div class='btn'><button class='btn1'>确认</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button class='btn2'>取消</button></div>
		<script type="text/javascript" src="../js/jquery-1.12.4.js" ></script>
		<script type="text/javascript" src="../layer-v2.4/layer/layer.js" ></script>
		<script>
			
			 var url = document.location.href.toString();
			 var u = url.split("=");
			 //alert(u[1]);//通过URL向下一个页面传输的id数据
			
			 $(".btn").css("display","none");
			 /*设置编辑权限按钮begin*/
			 var editlegStr="";
			<#if resList?seq_contains("ak/flightMessage/setleg")>			
				editlegStr+="<button onOff='false' class='editBtn searchBtn' >编辑</button>";
			</#if>	
			$("#setLeg").append(editlegStr);	
			 /*设置编辑权限按钮end*/
			
			 
			 $.ajax({
					type:"get",
					url:"../inventory/"+u[1]+"/segCabinList?temp="+Math.random(),
					//url:"../inventory/1563/segCabinList?temp="+Math.random(),
				    //  url:"../JSON/setLegInventory.json?temp="+Math.random(),
					async:false,
					dataType:"json",
					success:function(data){
						var tabHtml="";
						var optionStr="";
						$("#segflight").html("");
						$(".clear").empty();
						for(var i=0;i<data.data.length;i++){
							//下拉框的显示
							optionStr+="<option value="+data.data[i].id+">" + data.data[i].depAirport+"—"+data.data[i].arrAirport+ "</option>"
							
							//表格的展示
							tabHtml+="<table><thead class='f868686'><tr>"+
									 "<th>舱位</th>"+
									 "<th>开放数<strong class='fa2828 star'>*</strong></th>"+
									"<th>切位限制数<strong class='fa2828 star'>*</strong></th>"+
									"<th>散客限制数<strong class='fa2828 star'>*</strong></th>"+
									"<th>切位已售</th>"+
									"<th>散客已售</th>"+
									"<th>总已售</th>"+
									"<th style=display:none>id</th>"+
									"</tr>"+
								"</thead><tbody>"
							
							for(var j=0;j<data.data[i].cabinList.length;j++){
								var openCapacity;//开放数的处理
								if(data.data[i].cabinList[j].openCapacity>=0){
									openCapacity=data.data[i].cabinList[j].openCapacity;
									
								}else{
									openCapacity="";
									
								}
								var groupCapacity;//切位开放数的处理
								if(data.data[i].cabinList[j].groupCapacity>=0){
									groupCapacity=data.data[i].cabinList[j].groupCapacity;
								}else{
									groupCapacity="";
								}
								var individualCapacity;//散客开放数的处理
								if(parseInt(data.data[i].cabinList[j].individualCapacity)>=0){
									individualCapacity=data.data[i].cabinList[j].individualCapacity;
				
								}else{
									individualCapacity="";
									
								}
								//多等级舱位
								if(data.data[i].cabinList.length>3){
									tabHtml+="<tr>"+
												"<td class='f00aa99'>"+data.data[i].cabinList[j].cabinName+" (<span class=cabin>"+data.data[i].cabinList[j].cabin+"</span>)"+"</td>"+
												'<td class="font14px f60666">'+												
													'<input type="text" readonly class="openCapacity" value="'+openCapacity+'">'+
												'</td>'+
												'<td class="font14px f60666">'+												
													'<input type="text" readonly class="groupCapacity" value="'+groupCapacity+'">'+
												'</td>'+
												'<td class="font14px f60666">'+													 
													 '<input type="text" readonly class="individualCapacity" value="'+individualCapacity+'">'+
												'</td>'+
												"<td class='groupBooked font14px f60666'>"+data.data[i].cabinList[j].groupBooked+"</td>"+
												"<td class='individualBooked font14px f60666'>"+data.data[i].cabinList[j].individualBooked+"</td>"+
												"<td class='bookedSeat font14px f60666'>"+data.data[i].cabinList[j].bookedSeat+"</td>"+
												"<td class=list_id style=display:none>"+data.data[i].cabinList[j].id+"</td>"+
											"</tr>"	
									
								}else{
									tabHtml+="<tr>"+
												"<td class='f00aa99'>"+data.data[i].cabinList[j].cabinName+" (<span class=cabin>"+data.data[i].cabinList[j].cabin+"</span>)"+"</td>"+
												'<td class="font14px f60666"><input type="radio"  name="openCapacity'+data.data[i].cabinList[j].id+'"  id="openCapacity1" class="openCapacity1" checked   ><label for="openCapacity1">自动</label>'+
													'<input type="radio"  name="openCapacity'+data.data[i].cabinList[j].id+'"  id="openCapacity2" class="openCapacity2"   ><label for="openCapacity2"></label>'+
													'<input type="text" readonly class="openCapacity" value="'+openCapacity+'">'+
												'</td>'+
												'<td class="font14px f60666"><input type="radio"  name="groupCapacity'+data.data[i].cabinList[j].id+'" id="groupCapacity1" checked class="groupCapacity1"  ><label for="groupCapacity1">自动</label>'+
													'<input type="radio"  name="groupCapacity'+data.data[i].cabinList[j].id+'" id="groupCapacity2" class="groupCapacity2" ><label for="groupCapacity2"></label>'+
													'<input type="text" readonly class="groupCapacity" value="'+groupCapacity+'">'+
												'</td>'+
												'<td class="font14px f60666"><input type="radio"  name="individualCapacity'+data.data[i].cabinList[j].id+'" id="individualCapacity1" checked class="individualCapacity1"   ><label for="individualCapacity1">自动</label>'+
													 '<input type="radio"  name="individualCapacity'+data.data[i].cabinList[j].id+'" id="individualCapacity2" class="individualCapacity2" ><label for="individualCapacity2"></label>'+
													  '<input type="text" readonly class="individualCapacity" value="'+individualCapacity+'">'+
												'</td>'+
												"<td class='groupBooked font14px f60666'>"+data.data[i].cabinList[j].groupBooked+"</td>"+
												"<td class='individualBooked font14px f60666'>"+data.data[i].cabinList[j].individualBooked+"</td>"+
												"<td class='bookedSeat font14px f60666'>"+data.data[i].cabinList[j].bookedSeat+"</td>"+
												"<td class=list_id style=display:none>"+data.data[i].cabinList[j].id+"</td>"+
											"</tr>"										
								}																		
							}
							tabHtml+="</tbody></table>";							
						}
						$("#segflight").html(optionStr);
						$(".mainTab").append(tabHtml);
						
						/*单选按钮设置有数据时被选中状态和text输入框的背景颜色begin----*/
						var tableLength=$(".mainTab table").length;//获取表格的个数
						for(var i=0;i<tableLength;i++ ){
							var len=$(".mainTab table:eq("+i+")>tbody>tr").length;
							for(var j=0;j<len;j++){
								//散客开放数
								if(parseInt($(".mainTab table:eq("+i+")>tbody>tr .individualCapacity:eq("+j+")").val())>=0){
									$(".mainTab table:eq("+i+")>tbody>tr .individualCapacity2:eq("+j+")").prop('checked','checked');
									$(".mainTab table:eq("+i+")>tbody>tr .individualCapacity:eq("+j+")").css("background-color","#ffffff");
									$(".mainTab table:eq("+i+")>tbody>tr .individualCapacity:eq("+j+")").prop("readonly",false);
								}else{
									$(".mainTab table:eq("+i+")>tbody>tr>.individualCapacity1:eq("+j+")").prop('checked','checked');
								
									$(".mainTab table:eq("+i+")>tbody>tr .individualCapacity:eq("+j+")").prop("readonly",true);
								}
								//散客开放数 点击自动时候把值清空
								$(".mainTab table:eq("+i+")>tbody>tr .individualCapacity1:eq("+j+")").click(function(){
									$(this).parent().find(".individualCapacity").val("");
									$(this).parent().find(".individualCapacity").prop("readonly",true);
								})
							
								$(".mainTab table:eq("+i+")>tbody>tr .individualCapacity2:eq("+j+")").click(function(){
									$(this).parent().find(".individualCapacity").prop("readonly",false)
								})
								//切位开放数
								if(parseInt($(".mainTab table:eq("+i+")>tbody>tr .groupCapacity:eq("+j+")").val())>=0){
									$(".mainTab table:eq("+i+")>tbody>tr .groupCapacity2:eq("+j+")").prop('checked','checked');
									$(".mainTab table:eq("+i+")>tbody>tr .groupCapacity:eq("+j+")").css("background-color","#ffffff");
									$(".mainTab table:eq("+i+")>tbody>tr .groupCapacity:eq("+j+")").prop("readonly",false);
								}else{
									$(".mainTab table:eq("+i+")>tbody>tr>.groupCapacity1:eq("+j+")").prop('checked','checked');
								
									$(".mainTab table:eq("+i+")>tbody>tr .groupCapacity:eq("+j+")").prop("readonly",true);
								}
								//切位开放数 点击自动时候把值清空且设置为只读
								$(".mainTab table:eq("+i+")>tbody>tr .groupCapacity1:eq("+j+")").click(function(){
									$(this).parent().find(".groupCapacity").val("");
									$(this).parent().find(".groupCapacity").prop("readonly",true);
								})
								$(".mainTab table:eq("+i+")>tbody>tr .groupCapacity2:eq("+j+")").click(function(){
									$(this).parent().find(".groupCapacity").prop("readonly",false)
								})
								//开放数
								if(parseInt($(".mainTab table:eq("+i+")>tbody>tr .openCapacity:eq("+j+")").val())>=0){
									$(".mainTab table:eq("+i+")>tbody>tr .openCapacity2:eq("+j+")").prop('checked','checked');
									$(".mainTab table:eq("+i+")>tbody>tr .openCapacity:eq("+j+")").css("background-color","#ffffff");
									$(".mainTab table:eq("+i+")>tbody>tr .openCapacity:eq("+j+")").prop("readonly",false);
								}else{
									$(".mainTab table:eq("+i+")>tbody>tr>.openCapacity1:eq("+j+")").prop('checked','checked');
								
									$(".mainTab table:eq("+i+")>tbody>tr .openCapacity:eq("+j+")").prop("readonly",true);
								}
								//开放数 点击自动时候把值清空且设置为只读
								$(".mainTab table:eq("+i+")>tbody>tr .openCapacity1:eq("+j+")").click(function(){
									$(this).parent().find(".openCapacity").val("");
									$(this).parent().find(".openCapacity").prop("readonly",true)
								})
								
								$(".mainTab table:eq("+i+")>tbody>tr .openCapacity2:eq("+j+")").click(function(){
									$(this).parent().find(".openCapacity").prop("readonly",false)
								})
							}
						}
						/*单选按钮设置有数据时被选中状态和text输入框的背景颜色end---*/
						
						
					}
					
				});	 
		 //控制对应的表格和下拉框的显示
		 $(".mainTab table").hide();//默认全部隐藏
		 var index=$("#segflight").find("option:selected").index();//获取被选中项的下标值
		 $(".mainTab table").eq(index).show().siblings("table").hide();
		 
		 //当select某一项被选中时候
		 $("#segflight").change(function(){
			 var index=$(this).find("option:selected").index();//获取被选中项的下标值
			 $(".mainTab table").eq(index).show().siblings("table").hide();
		 });
		 
		 
		/*以下为航节部分根据航节选择查看对应航节得详情或者修改begin*/
		$.ajax({
					type:"get",
					url:"../inventory/"+u[1]+"/legCabinList?temp="+Math.random(),
					//url:"../inventory/1563/segCabinList?temp="+Math.random(),
				    //  url:"../JSON/setLegInventory.json?temp="+Math.random(),
					async:false,
					dataType:"json",
					success:function(data){
						var tabHtml="";
						var optionStr="";
						$("#flightBoat").html("");
						$(".flightBoatTab").empty(); // 将表格的div清空
						for(var i=0;i<data.data.length;i++){
							//下拉框的显示
							optionStr+="<option value="+data.data[i].id+">" + data.data[i].depAirport+"—"+data.data[i].arrAirport+ "</option>"
							
							//表格的展示
							tabHtml+="<table><thead class='f868686'><tr>"+
									 "<th>舱位</th>"+
									 "<th>物理数</th>"+
									 "<th>最大数<strong class='fa2828 star' >*</strong> </th>"+
									 "<th>开放数<strong class='fa2828 star'>*</strong></th>"+
									"<th>切位限制数<strong class='fa2828 star'>*</strong></th>"+
									"<th>散客限制数<strong class='fa2828 star'>*</strong></th>"+
									"<th>切位已售</th>"+
									"<th>散客已售</th>"+
									"<th>总已售</th>"+
									"<th>未售数 </th>"+
									"<th>物理可售 </th>"+
									"<th style=display:none>id</th>"+
									"</tr>"+
								"</thead><tbody>"
							
							for(var j=0;j<data.data[i].invLegCabinVos.length;j++){
								
								tabHtml+="<tr>"+
											"<td class='f00aa99'>"+data.data[i].invLegCabinVos[j].cabinName+" (<span class=cabin>"+data.data[i].invLegCabinVos[j].cabin+"</span>)"+"</td>"+
											'<td class="capacity font14px f60666">'+data.data[i].invLegCabinVos[j].capacity+'</td>'+
											'<td class="font14px f60666"><input type="text" class="maxCapacity"  value='+data.data[i].invLegCabinVos[j].maxCapacity+'></td>'+
											'<td class="font14px f60666"><input type="text" class="openCapacity"  value='+data.data[i].invLegCabinVos[j].openCapacity+'></td>'+
											'<td class="font14px f60666"><input type="text" class="groupCapacity"  value='+data.data[i].invLegCabinVos[j].groupCapacity+'></td>'+
											'<td class="font14px f60666"><input type="text" class="individualCapacity"  value='+data.data[i].invLegCabinVos[j].individualCapacity+'></td>'+
											"<td class='groupBooked font14px f60666'>"+data.data[i].invLegCabinVos[j].groupBooked+"</td>"+
											"<td class='individualBooked font14px f60666'>"+data.data[i].invLegCabinVos[j].individualBooked+"</td>"+
											"<td class='bookedSeat font14px f60666'>"+data.data[i].invLegCabinVos[j].bookedSeat+"</td>"+
											"<td class='unsaldSeat font14px f60666'>"+data.data[i].invLegCabinVos[j].unsaldSeat+"</td>"+
											"<td class='unsaldCapacity font14px f60666'>"+data.data[i].invLegCabinVos[j].unsaldCapacity+"</td>"+
											"<td class=legList_id style=display:none>"+data.data[i].invLegCabinVos[j].id+"</td>"+
											"</tr>"	
											
											
							}
							tabHtml+="</tbody></table>";
								
							
						}
						$("#flightBoat").html(optionStr);
						$(".flightBoatTab").append(tabHtml);
									
					}
					
				});	 
		 //控制对应的表格和下拉框的显示
		 $(".flightBoatTab table").hide();//默认全部隐藏
		 var index=$("#flightBoat").find("option:selected").index();//获取被选中项的下标值
		 $(".flightBoatTab table").eq(index).show().siblings("table").hide();
		 
		 //当select某一项被选中时候
		 $("#flightBoat").change(function(){
			 var index=$(this).find("option:selected").index();//获取被选中项的下标值
			 $(".flightBoatTab table").eq(index).show().siblings("table").hide();
		 });
		 
	//	$("input[type=text]").length
		/*航节部分根据航节选择查看对应航节得详情或者修改end*/
		/*以下为控制编辑和查看两种不同的呈现方式*/
			$("input[type=text]").prop("readonly",true);
			$("input[type=radio]").prop("disabled",true);
    	 if($(".editBtn").length>0){//存在编辑按钮
				 $(".editBtn").click(function(){//点击时候执行编辑
					 var onOff = $(this).attr("onOff");				 
					 if(onOff=="false"){
						 $(".btn").css("display","block");
						 $("input[type=text]").prop("readonly",false);
						 $("input[type=radio]").prop("disabled",false);
						 $(".star").css("display","inline");
						 $(this).attr("onOff","true");
					 }else{
						 $(".btn").css("display","none");
						 $("input[type=text]").prop("readonly",true);
						 $("input[type=radio]").prop("disabled",true);
						 $(".star").css("display","none");
						 $(this).attr("onOff","false");
					 }										
				 });
				 
			 }
		
			 $(".btn1").click(function(){
				var seglegAll={}; //用于存放航节和航段的数据对象
				var tableLength=$(".mainTab table").length;//获取表格的个数
				var dataArr = [];//定义数组用于存放每条数据
				for(var i=0;i<tableLength;i++ ){
					var len=$(".mainTab table:eq("+i+")>tbody>tr").length;
					for(var j=0;j<len;j++){
						var json={};
						json.cabin=$(".mainTab table:eq("+i+")>tbody>tr .cabin").eq(j).text();//舱位
						json.groupBooked=$(".mainTab table:eq("+i+")>tbody>tr>.groupBooked").eq(j).text();//切位已售
						json.individualBooked=$(".mainTab table:eq("+i+")>tbody>tr>.individualBooked").eq(j).text();//散客已售
						json.bookedSeat=$(".mainTab table:eq("+i+")>tbody>tr>.bookedSeat").eq(j).text();//总已售
						json.id=$(".mainTab table:eq("+i+")>tbody>tr>.list_id").eq(j).text();//当前行的id
						/*开放数的输入验证begin*/
						if($(".mainTab table:eq("+i+")>tbody>tr .openCapacity2").eq(j).is(":checked")){
							if($(".mainTab table:eq("+i+")>tbody>tr .openCapacity").eq(j).val()==""){
								layer.msg("航段开放数不能为空",{icon: 2,time:1000})
								return false;
							}else if(!/^[0-9]{1,3}$/.test($(".mainTab table:eq("+i+")>tbody>tr .openCapacity").eq(j).val())){
								layer.msg("航段开放数必须为不超过3位的数字",{icon: 2,time:1000})
								return false;
							}
						}
						/*开放数的输入验证end*/
					
						//开放数
						if($(".mainTab table:eq("+i+")>tbody>tr .openCapacity").eq(j).val()==""){
							json.openCapacity=-1;
						}else{
							json.openCapacity=$(".mainTab table:eq("+i+")>tbody>tr .openCapacity").eq(j).val();
						}
						
						/*切位开放数的输入验证begin*/
						if($(".mainTab table:eq("+i+")>tbody>tr .groupCapacity2").eq(j).is(":checked")){
							if($(".mainTab table:eq("+i+")>tbody>tr .groupCapacity").eq(j).val()==""){
								layer.msg("航段切位限制数不能为空",{icon: 2,time:1000})
								return false;
							}else if(!/^[0-9]{1,3}$/.test($(".mainTab table:eq("+i+")>tbody>tr .groupCapacity").eq(j).val())){
								layer.msg("航段切位限制数必须为不超过3位的数字",{icon: 2,time:1000})
								return false;
							}
						}
						/*切位开放数的输入验证end*/
						//切位开放数
						if($(".mainTab table:eq("+i+")>tbody>tr .groupCapacity").eq(j).val()==""){
							json.groupCapacity=-1;
						}else{
							json.groupCapacity=$(".mainTab table:eq("+i+")>tbody>tr .groupCapacity").eq(j).val();
						}
						/*散客开放数的输入验证begin*/
						if($(".mainTab table:eq("+i+")>tbody>tr .individualCapacity2").eq(j).is(":checked")){
							if($(".mainTab table:eq("+i+")>tbody>tr .individualCapacity").eq(j).val()==""){
								layer.msg("航段散客限制数不能为空",{icon: 2,time:1000})
								return false;
							}else if(!/^[0-9]{1,3}$/.test($(".mainTab table:eq("+i+")>tbody>tr .individualCapacity").eq(j).val())){
								layer.msg("航段散客限制数必须为不超过3位的数字",{icon: 2,time:1000})
								return false;
							}
						}
						/*散客开放数的输入验证end*/
						//散客开放数
						if($(".mainTab table:eq("+i+")>tbody>tr .individualCapacity").eq(j).val()==""){
							json.individualCapacity=-1;
						}else{
							json.individualCapacity=$(".mainTab table:eq("+i+")>tbody>tr .individualCapacity").eq(j).val();
						}
						dataArr.push(json);
					}
					
				}
			//	console.log(dataArr);
				/*以下为获取航节表格的相关信息 */
				var flightBoatLength=$(".flightBoatTab table").length;//获取表格的个数
				var invLegCabinVos = [];//定义数组用于存放每条数据
				for(var i=0;i<flightBoatLength;i++ ){
					var legLen=$(".flightBoatTab table:eq("+i+")>tbody>tr").length;
					for(var j=0;j<legLen;j++){
						var json={};
						/*航节最大数的输入验证begin*/
						if($(".flightBoatTab table:eq("+i+")>tbody>tr .maxCapacity").eq(j).val()==""){
							layer.msg("航节最大数不能为空",{icon: 2,time:1000})
							return false;
						}else if(!/^[0-9]{1,3}$/.test($(".flightBoatTab table:eq("+i+")>tbody>tr .maxCapacity").eq(j).val())){
							layer.msg("航节最大数必须为不超过3位的数字",{icon: 2,time:1000})
							return false;
						}
						/*航节最大数的输入验证end*/
						/*航节开放数的输入验证begin*/
						if($(".flightBoatTab table:eq("+i+")>tbody>tr .openCapacity").eq(j).val()==""){
							layer.msg("航节开放数不能为空",{icon: 2,time:1000})
							return false;
						}else if(!/^[0-9]{1,3}$/.test($(".flightBoatTab table:eq("+i+")>tbody>tr .openCapacity").eq(j).val())){
							layer.msg("航节开放数必须为不超过3位的数字",{icon: 2,time:1000})
							return false;
						}
						/*航节开放数的输入验证end*/
						/*航节切位限制数的输入验证begin*/
						if($(".flightBoatTab table:eq("+i+")>tbody>tr .groupCapacity").eq(j).val()==""){
							layer.msg("航节切位限制数不能为空",{icon: 2,time:1000})
							return false;
						}else if(!/^[0-9]{1,3}$/.test($(".flightBoatTab table:eq("+i+")>tbody>tr .groupCapacity").eq(j).val())){
							layer.msg("航节切位限制数必须为不超过3位的数字",{icon: 2,time:1000})
							return false;
						}
						/*航节切位限制数的输入验证end*/
						/*航节散客限制数的输入验证begin*/
						if($(".flightBoatTab table:eq("+i+")>tbody>tr .individualCapacity").eq(j).val()==""){
							layer.msg("航节散客限制数不能为空",{icon: 2,time:1000})
							return false;
						}else if(!/^[0-9]{1,3}$/.test($(".flightBoatTab table:eq("+i+")>tbody>tr .individualCapacity").eq(j).val())){
							layer.msg("航节散客限制数必须为不超过3位的数字",{icon: 2,time:1000})
							return false;
						}
						/*航节散客限制数的输入验证end*/
						json.cabin=$(".flightBoatTab table:eq("+i+")>tbody>tr .cabin").eq(j).text();//舱位
						json.capacity=$(".flightBoatTab table:eq("+i+")>tbody>tr>.capacity").eq(j).text();//物理数
						json.maxCapacity=$(".flightBoatTab table:eq("+i+")>tbody>tr .maxCapacity").eq(j).val(); // 最大数
						json.openCapacity=$(".flightBoatTab table:eq("+i+")>tbody>tr .openCapacity").eq(j).val();  // 开放数
						json.groupCapacity=$(".flightBoatTab table:eq("+i+")>tbody>tr .groupCapacity").eq(j).val();  // 切位限制数
						json.individualCapacity=$(".flightBoatTab table:eq("+i+")>tbody>tr .individualCapacity").eq(j).val();  //散客限制数
						json.groupBooked=$(".flightBoatTab table:eq("+i+")>tbody>tr>.groupBooked").eq(j).text();//切位已售
						json.individualBooked=$(".flightBoatTab table:eq("+i+")>tbody>tr>.individualBooked").eq(j).text();//散客已售
						json.bookedSeat=$(".flightBoatTab table:eq("+i+")>tbody>tr>.bookedSeat").eq(j).text();//总已售
						json.unsaldSeat=$(".flightBoatTab table:eq("+i+")>tbody>tr>.unsaldSeat").eq(j).text();// 未售数
						json.unsaldCapacity=$(".flightBoatTab table:eq("+i+")>tbody>tr>.unsaldCapacity").eq(j).text();// 物理可售
						json.id=$(".flightBoatTab table:eq("+i+")>tbody>tr>.legList_id").eq(j).text();//当前行的id
					
						invLegCabinVos.push(json);
					}
					
				}
				seglegAll.segCabinList=dataArr;
				seglegAll.legCabinList=invLegCabinVos;
				layer.msg('修改中...', {icon: 16,shade: 0.01});
				 //将得到的数据list传输给后台
				 $.ajax({
						type:"post",
						url:"../inventory/updateCabinList?temp="+Math.random(),
						contentType:'application/json;charset=utf-8',
						data:JSON.stringify(seglegAll),
						async:true,
						success:function(data){
							var data=JSON.parse(data);
							//alert(data.message);
							//layer.msg(data.message);
							if(data.status.toString()=="1001"){
								layer.msg(data.message, {icon: 1,time:1000},function(){
									var index = parent.layer.getFrameIndex(window.name);//获取弹窗索引
									parent.layer.close(index);//关闭弹窗
								});			
							}else{
								//layer.msg(data.message, {icon: 2,time:1000})
								layer.confirm(data.message, {
									title:['设置失败 ','background-color:#00aa98;color:#fff'],
								   	btn: ['确定'] //按钮
								}, function(){
									layer.closeAll('dialog');
								});
							}
						}
					});
				  
				  
				
			 });
			 //取消执行关闭窗口
    		$(".btn2").click(function(){
    			var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
   				 parent.layer.close(index);
    		});
			 
			 
		</script>
	</body>
</html>
